package com.example.messagemodule.adapter;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.messagemodule.R;
import com.example.messagemodule.entity.DirectionUsingMedicineEntity;

import java.util.List;

public class UsageAdapter extends BaseQuickAdapter<DirectionUsingMedicineEntity.DataBean.UsageBean, BaseViewHolder> {



    public UsageAdapter(@Nullable List<DirectionUsingMedicineEntity.DataBean.UsageBean> data) {
        super(R.layout.activity_direction_using_medicine_item1, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, DirectionUsingMedicineEntity.DataBean.UsageBean item) {



        helper.setText(R.id.activity_direction_using_medicine_item1_title,item.getDrugName());
        helper.setText(R.id.activity_direction_using_medicine_item1_specification,item.getSpec());

        ForegroundColorSpan span_color = new ForegroundColorSpan(mContext.getResources().getColor(R.color.color_1A1A1A));

        StyleSpan span_style = new StyleSpan(Typeface.BOLD);//加粗
        SpannableString spannablediseaseList = new SpannableString("适应症：" + item.getDiseaseList());
        spannablediseaseList.setSpan(span_color, 0, 4, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        spannablediseaseList.setSpan(span_style, 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        helper.setText(R.id.activity_direction_using_medicine_item1_diseaseList,spannablediseaseList);
        SpannableString spannableUsageAndDosage = new SpannableString("用法用量：" + item.getUsageAndDosage());
        spannableUsageAndDosage.setSpan(span_color, 0, 5, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        spannableUsageAndDosage.setSpan(span_style, 0, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        helper.setText(R.id.activity_direction_using_medicine_item1_UsageAndDosage,spannableUsageAndDosage);
    }
}
